package com.cyrus.vueboot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cyrus.vueboot.mapper.log.LoginLogMapper;
import com.cyrus.vueboot.pojo.log.loginLog;
import com.cyrus.vueboot.service.LoginLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: Cyrus
 * @CreateDate: 2020/11/16
 */
@Service
public class LoginLogServiceImpl extends ServiceImpl<LoginLogMapper, loginLog> implements LoginLogService {
    @Autowired
    private LoginLogMapper loginLogMapper;
    @Override
    public IPage Search(Integer page, Integer size, String key) {
        Page<loginLog> page1 = new Page(page,size);
        IPage<loginLog> iPage = loginLogMapper.selectPage(page1, new QueryWrapper<loginLog>().lambda().like(loginLog::getLogindate,key));
        return iPage;
    }

    @Override
    public void deleteLogs(Long[] ids) {
        if (ids != null) {
            for (Long id : ids) {
                loginLogMapper.deleteById(id);
            }
        }
    }
}
